<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .frame {
        width: 800;
        height: 400;
        margin: 150px auto;
        display: flex;
      }
      .box {
        width: 200px;
        height: 400px;
        position: relative;
        transform-style: preserve-3d;
        transition: transform 1s;
        /* overflow: hidden; */
      }
      .box div {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
      }
      .box div:nth-of-type(1) {
        transform: rotateX(0deg) translateZ(180px);
        background-color: skyblue;
      }
      .box div:nth-of-type(2) {
        transform: rotateX(90deg) translateZ(180px);
        background-color: rebeccapurple;
      }
      .box div:nth-of-type(3) {
        transform: rotateX(180deg) translateZ(180px);
        background-color: coral;
      }
      .box div:nth-of-type(4) {
        transform: rotateX(270deg) translateZ(180px);
        background-color: darkolivegreen;
      }
    </style>
  </head>
  <body>
    <div class="frame" id="frame">
      <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
      </div>
      <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
      </div>
      <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
      </div>
      <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
      </div>
    </div>
    <button>下一页</button>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
      // var f = document.querySelector('#frame')

      // var box = document.querySelector('.box')
      // var i = 0
      // f.addEventListener('click', function () {
      //   i++
      //   //给box绑定属性
      //   box.style.transform = 'rotateX(' + -i * 90 + 'deg)'
      // })
      var box = document.querySelectorAll('.box')
      let i = 0
      $('button').click(function () {
        i++
        box.forEach(function (v, index) {
          setTimeout(() => {
            v.style.transform = 'rotateX(' + -i * 90 + 'deg)'
          }, index * 100)
        })
      })
    </script>
  </body>
</html>
